package leetcodecompetition.D358;

/**
 * @Author: Siantar
 * @Date: 2023-08-13-10:32
 * @Description: 1.0
 */
public class T6939 {
    public int maxSum(int[] nums) {
        int res = -1;
        int[] maxS = new int[10];
        for (int num : nums) {
            int max = 0, t=num;
            while (t != 0) {
                max = Math.max(max, t % 10);
                t /= 10;
                System.out.println(max);
            }
            if (maxS[max] != 0) {
                res = Math.max(res, num + maxS[max]);
                System.out.println(max);
            }
            maxS[max] = Math.max(maxS[max], num);
        }
        return res;
    }
}
